<template>
  <div class="records">
    <div class="top-title">跟进记录</div>
    <div class="top-radio">
      <el-radio-group v-model="topRadio">
        <el-radio-button label="0">全部</el-radio-button>
        <el-radio-button label="1">昨日</el-radio-button>
        <el-radio-button label="2">本周</el-radio-button>
        <el-radio-button label="3">自定义</el-radio-button>
      </el-radio-group>
      <el-tooltip
        class="item"
        effect="dark"
        content="本周指从上个周六开始到本周周五结束"
        placement="top"
        style="margin-left: 20px"
      >
        <el-link type="primary"> <i class="el-icon-info"></i></el-link>
      </el-tooltip>
      <el-date-picker
        v-model="topDate"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        style="margin-left: 200px"
        :disabled="topRadio != 3"
      >
      </el-date-picker>
    </div>
    <div class="mid-context">
      <div class="left-context">
        <el-table :data="tableData" border style="margin-top: 20px">
          <el-table-column prop="date" label="战队名称" :align="tableAlign"> </el-table-column>
          <el-table-column prop="date" label="新增" :align="tableAlign"> </el-table-column>
          <el-table-column prop="name" label="退定" :align="tableAlign"> </el-table-column>
          <el-table-column prop="address" label="差额" :align="tableAlign"> </el-table-column>
        </el-table>
      </div>
      <div class="right-context">
        <div id="recordsMain" style="height: 600px;"></div>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      topRadio: "0",
      topDate: "",
      tableAlign:'center',
    };
  },
  methods: {
    initCharts() {
      var chartDom = document.getElementById("recordsMain");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        legend: {
            selectedMode: false,
        },
        tooltip: {},
        dataset: {
          source: [
            ["product", "2015", "2016", "2017"],
            ["Matcha Latte", 43.3, 85.8, 93.7],
            ["Milk Tea", 83.1, 73.4, 55.1],
            ["Cheese Cocoa", 86.4, 65.2, 82.5],
            ["Walnut Brownie", 72.4, 53.9, 39.1],
          ],
        },
        xAxis: { type: "category" },
        yAxis: {},
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [{ type: "bar" }, { type: "bar" }, { type: "bar" }],
      };

      option && myChart.setOption(option);
      window.addEventListener('resize', function () {
                    myChart.resize();
                });

    },
  },
  mounted() {
    this.initCharts()
  },
};
</script>
<style lang="scss" scoped>
.records {
  margin-top: 30px;
  width: 100%;

  .top-title {
    border-left: 8px solid #409eff;
    margin: 20px 0;
    padding: 3px 0 3px 25px;
    font-size: 18px;
    font-weight: bold;
  }

  .top-radio {
    display: flex;
    justify-content: center;
  }

  .mid-context {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    .left-context {
      width: 47%;
    }

    .right-context {
      width: 47%;

      .right-button {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
    }
  }
}
</style>
